package com.qiangshi.alarmLog.service.impl;

import java.util.List;
import java.util.Objects;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qiangshi.alarmLog.domain.to.QsAlarmLogTO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import com.qiangshi.alarmLog.mapper.QsAlarmLogMapper;
import com.qiangshi.alarmLog.domain.QsAlarmLog;
import com.qiangshi.alarmLog.service.IQsAlarmLogService;

/**
 * 报警数据Service业务层处理
 *
 * @author qiangshi
 * @date 2022-03-08
 */
@Service
public class QsAlarmLogServiceImpl extends ServiceImpl<QsAlarmLogMapper, QsAlarmLog> implements IQsAlarmLogService
{


    /**
     * 查询报警数据列表
     *
     *
     * @param qsAlarmLog 报警数据
     * @return 报警数据
     */
    @Override
    public List<QsAlarmLog> selectQsAlarmLogList(QsAlarmLogTO qsAlarmLog)
    {
        QueryWrapper<QsAlarmLog> queryWrapper = new QueryWrapper<QsAlarmLog>();
        if(CollectionUtils.isNotEmpty(qsAlarmLog.getCaseList())){
            queryWrapper.lambda().in(QsAlarmLog::getAlarmCaseNumber,qsAlarmLog.getCaseList());
        }
        if (Objects.nonNull(qsAlarmLog.getStartTime())&&Objects.nonNull(qsAlarmLog.getEndTime())){
            queryWrapper.lambda().between(QsAlarmLog::getCreateTime,qsAlarmLog.getStartTime(),qsAlarmLog.getEndTime());
        }
        if(Objects.nonNull(qsAlarmLog.getAlarmType())){
            queryWrapper.lambda().in(QsAlarmLog::getAlarmType,qsAlarmLog.getAlarmType());
        }
        return baseMapper.selectList(queryWrapper);
    }

}
